package com.example.siyun.controller.permissionscontroller;

import com.example.siyun.pojo.EnumPojo;
import com.example.siyun.pojo.Loginlog;
import com.example.siyun.service.permissionsservice.BackmanageloginService;
import com.example.siyun.service.permissionsservice.FrontmanageloginService;
import com.example.siyun.util.PageResult;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * @Auther: 全
 * @Date: 2022/9/26 09:33
 * @Description:权限管理模块前台人员登录
 */
@Slf4j
@RestController
public class FrontmanagerloginController {
    @Autowired
    private FrontmanageloginService frontmanageloginService;
    /**
     * 获取前台人员登录日志
     * @return 返回前台人员登录日志
     */
    @RequestMapping("/advanced/getfrontmanagelogin")
    public PageResult getFrontManageLogin(Loginlog loginlog,int page, int limit) {
        log.info("获取前台人员登录日志");
        Map<String, Object> map = new HashMap<>();
        PageHelper.startPage(page, limit);
        List<Loginlog> list = frontmanageloginService.getBackManageLogin(loginlog, EnumPojo.STATE_1,EnumPojo.VALUE_DEL_0);
        PageInfo<Loginlog> pageInfo = new PageInfo<>(list);
        PageResult pageResult=new PageResult();
        pageResult.setState(0);
        pageResult.setMessage("成功");
        pageResult.setTotal(pageInfo.getTotal());
        pageResult.setData(pageInfo.getList());
        log.info("获取前台人员登录日志成功");
        return pageResult;
    }
    /**
     * 通过id删除对应前台人员数据
     */
    @RequestMapping("/advanced/delfrontmanagelogin")
    public PageResult delCourseTable(int id){
        log.info("通过id删除对应前台人员数据");
        frontmanageloginService.delFrontManageLogin(id,EnumPojo.VALUE_DEL_1);
        PageResult pageResult=new PageResult();
//        pageResult.setStatus(200);
        log.info("通过id删除对应前台人员数据成功");
        return pageResult;
    }
}
